import xadmin
from django.contrib.auth.models import AbstractUser
from django.db import models
import time

# Create your models here.


class User(AbstractUser): # 继承AbstractUser类，实际上django的User也是继承他，我们要做的就是用自己的类代替django自己的User
    is_man = (
        (2, '女'),
        (1, '男')
    )
    is_status = (
        (0, '否'),
        (1, '是')
    )
    nickname = models.CharField(verbose_name="昵称", max_length=250,blank=True,null=True)
    tel = models.CharField(verbose_name="电话" ,max_length=100,blank=True,null=True)
    avatar = models.ImageField(verbose_name='头像', upload_to='avatar/{}/'.format(int(time.time())), blank=True, null=True)
    realname = models.CharField(verbose_name="真实姓名", max_length=200,null=True,blank=True)
    gender = models.IntegerField(choices=is_man,verbose_name="性别",blank=True,null=True,default=0)
    email = models.CharField(verbose_name="邮箱",max_length=100,blank=True,null=True)
    email_status = models.IntegerField(choices=is_status,verbose_name="邮箱状态",default=0,blank=True,null=True)
    birth = models.CharField(verbose_name="出生日期",max_length=100,null=True,blank=True)
    introduction = models.CharField(verbose_name="简介",max_length=250,null=True,blank=True)
    last_ip_add = models.CharField(verbose_name="上次登录ip", max_length=250, null=True, blank=True)
    token = models.CharField(verbose_name="Token",max_length=250,null=True,blank=True)
    class Meta:
        verbose_name = u'用户详情'
        verbose_name_plural = u"用户详情"
